<extend name="Layout/ins_page" />
<block name="content">
	{:W('PageHeader/new_search',array('name'=>$folder_name,'search'=>'M'))}
	<form method="post" name="form_adv_search" id="form_adv_search">
		<div class="adv_search panel panel-default <php>echo empty($_REQUEST) ? 'hidden' : '';</php>"  id="adv_search">
			<div class="panel-heading">
				<div class="row">
					<h4 class="col-xs-6">入库检验查询</h4>
					<div class="col-xs-6 text-right">
						<a  class="btn btn-sm btn-info" onclick="submit_adv_search();">搜索</a>
						<a  class="btn btn-sm btn-info" href="{:U('check')}">重置</a>
					</div>
				</div>
			</div>
			<div class="panel-body">
				<div class="form-group col-sm-6">
					<label class="col-sm-4 control-label" for="content">产品名称：</label>
					<div class="col-sm-8">
						<input class="form-control" id="product" type="text" name="product" value="{$product}"/>
					</div>
				</div>
			</div>
		</div>
	</form>
	<div class="space-8"></div>
	<div class="ul_table ul_table_responsive">
		<ul class="in-check-parent">
			<li class="thead">
				<span class="col-8">提交人</span>
				<span class="col-8">产品名称</span>
				<span class="col-10">入库数量</span>
				<span class="col-10">状态</span>
				<span class="col-10">时间</span>
				<span class="col-6">操作</span>
			</li>
			<empty name="list">
				<li class="no-data">
					没找到数据
				</li>
				<else/>
				<foreach name="list" item="vo">
					<li class="tbody in-check-list">
							<span class="col-8">{$vo.user_name}</span>
							<span class="col-8">{$vo.product}</span>
							<span class="col-10">
								<input name="product_num" type="text" value="{$vo.number}" class="col-6 product-num" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" onafterpaste="this.value=this.value.replace(/[^0-9]/g,'')"/>
							</span>
							<span class="col-10">
							    <if condition="(0 eq $vo['status'])">未审核</if>
								<if condition="(1 eq $vo['status'])">入库拒绝</if>
								<if condition="(2 eq $vo['status'])">入库成功</if>
							</span>
							<span class="col-10">{$vo.create_at}</span>
							<span class="col-6 col-sm-end">
								<if condition="(0 eq $vo['status'])">
									<a href="javascript:;" class="check-inreceive"  log-id="{$vo.id}" task-product-id="{$vo.task_product_id}" product="{$vo.product}">接受</a>&nbsp;
									<a href="javascript:;" class="check-inreject"   log-id="{$vo.id}" task-product-id="{$vo.task_product_id}">拒绝</a>&nbsp;
								    <a href="javascript:;" class="check-indelete"  log-id="{$vo.id}" task-product-id="{$vo.task_product_id}" >删除</a>
							    </if>
							</span>
						</>
					</li>
				</foreach>
				<div class="pagination">
					{$page}
				</div>
			</empty>
		</ul>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		// 删除提交仓库的产品
		$('.in-check-list').on('click','.check-indelete',function(event){
			var _this = $(this);
			var log_id = _this.attr('log-id');
			var product = _this.attr('product');// 接受
			var reason ='确定删除'+product;
			ui_confirm(reason, function() {
				sendAjax("{:U('indelete')}",'log_id='+log_id, function(data) {
					if (data.status) {
						location.reload();
					} else {
						ui_error(data.info);
					}
				});	
			});
		})	
		
		// 拒绝提交仓库的产品
		$('.in-check-list').on('click','.check-inreject',function(event){
			var _this = $(this);
			var log_id = _this.attr('log-id');
			var product = _this.attr('product');// 接受
			var reason ='确定拒绝'+product;
			ui_confirm(reason, function() {
				sendAjax("{:U('inreject')}",'log_id='+log_id, function(data) {
					if (data.status) {
						location.reload();
					} else {
						ui_error(data.info);
					}
				});	
			});
		})
		
		// 接受提交仓库的产品
		$('.in-check-list').on('click','.check-inreceive',function(event){
			var _this = $(this);
			var log_id = _this.attr('log-id');
			var product = _this.attr('product');// 接受
			var num = _this.parents('.in-check-list').find('.product-num').val();
			var reason ='确定接受'+product;
			ui_confirm(reason, function() {
				sendAjax("{:U('inreceive')}",'log_id='+log_id+'&num='+num, function(data) {
					if (data.status) {
						location.reload();
					} else {
						ui_error(data.info);
					}
				});	
			});
		})
	</script>
</block>